
package statcomponent;

import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Predicate;

/**
 * 需要统计的字段抽象
 *
 * @author chenfoxin
 * @date 2022年09月01日 9:14
 */
public class StatAttribute<T,R,U,R1> {

    /**
     * 提取字段方案
     */
    private Function<T,R> function;

    /**
     * 成立条件
     */
    private Predicate<T> predicate;

    /**
     * 计算规则
     */
    private AbstractStatRule<R,R1> abstractStatRule;

    /**
     * 处理结果函数
     */
    private BiConsumer<U,R1> resultProcessConsumer;


    public StatAttribute(Function<T,R> function,
                         AbstractStatRule<R,R1> abstractStatRule,
                         BiConsumer<U,R1> resultProcessConsumer) {
        this.function = function;
        this.abstractStatRule = abstractStatRule;
        this.resultProcessConsumer = resultProcessConsumer;
    }

    public Function<T, R> getFunction() {
        return function;
    }

    public void setFunction(Function<T, R> function) {
        this.function = function;
    }

    public Predicate<T> getPredicate() {
        return predicate;
    }

    public void setPredicate(Predicate<T> predicate) {
        this.predicate = predicate;
    }

    public AbstractStatRule<R, R1> getAbstractStatRule() {
        return abstractStatRule;
    }

    public void setAbstractStatRule(AbstractStatRule<R, R1> abstractStatRule) {
        this.abstractStatRule = abstractStatRule;
    }

    public BiConsumer<U, R1> getResultProcessConsumer() {
        return resultProcessConsumer;
    }

    public void setResultProcessConsumer(BiConsumer<U, R1> resultProcessConsumer) {
        this.resultProcessConsumer = resultProcessConsumer;
    }
}